Skip to content

fix(static): support HEAD without opening files#2645

Open
paulkagiri wants to merge 4 commits into
falconry:masterfrom
paulkagiri:static-routes-head-support
Open

fix(static): support HEAD without opening files#2645
paulkagiri wants to merge 4 commits into
falconry:masterfrom
paulkagiri:static-routes-head-support

Conversation

@paulkagiri
Copy link
Copy Markdown

Summary of Changes

Static routes now handle HEAD separately from GET: they compute the same response metadata without opening a file stream, preserve range headers for ranged HEAD requests, and return 405 Method Not Allowed for unsupported methods. OPTIONS now advertises both GET and HEAD.

Related Issues

Closes #2337

Pull Request Checklist

  • Applied changes to both WSGI and ASGI code paths and interfaces (where applicable).
  • Added tests for changed code.
  • Performed automated tests and code quality checks by running tox.
  • Prefixed code comments with GitHub nick and an appropriate prefix.
  • Coding style is consistent with the rest of the framework.
  • Updated documentation for changed code.
  • Changes have towncrier news fragments under docs/_newsfragments/, with the file name format {issue_number}.{fragment_type}.rst.
  • LLM output, if any, has been carefully reviewed and tested by a human developer.

Testing performed:

  • python -m pytest tests/test_static.py -q
  • git diff --check

Copy link
Copy Markdown
Member

@vytas7 vytas7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, and thanks for this PR.
Please check the failing CI, most of the gates fail on your changes.

@vytas7
Copy link
Copy Markdown
Member

vytas7 commented May 22, 2026

Hi again @paulkagiri, have you have a chance to review the CI failures?

@paulkagiri
Copy link
Copy Markdown
Author

paulkagiri commented May 23, 2026

Addressed the CI failures from the review.

Changes made:

  • Extracted static file lookup into a helper to bring StaticRoute.__call__ back under the Ruff complexity threshold.
  • Fixed the long test line flagged by Ruff.
  • Updated the CORS static-route OPTIONS expectation now that static routes advertise both GET and HEAD.

Validation:

  • python -m tox -e pep8
  • python -m tox -e ruff
  • python -m tox -e mintest
  • git diff --check

@codecov
Copy link
Copy Markdown

codecov Bot commented May 23, 2026

Codecov Report

❌ Patch coverage is 82.75862% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.87%. Comparing base (eddfeb4) to head (63f3ca0).

Files with missing lines Patch % Lines
falcon/routing/static.py 82.75% 8 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##            master    #2645      +/-   ##
===========================================
- Coverage   100.00%   99.87%   -0.13%     
===========================================
  Files           64       64              
  Lines         7976     8010      +34     
  Branches      1102     1109       +7     
===========================================
+ Hits          7976     8000      +24     
- Misses           0        8       +8     
- Partials         0        2       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vytas7
Copy link
Copy Markdown
Member

vytas7 commented May 23, 2026

Can you please run tox without any parameters (i.e., with the default environments) on your side to verify before pushing?
(It should be easy regardless whether you are a human or AI.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proper HEAD support for static routes

2 participants